package com.ruoyi.dazhuwx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.abuwx.domain.AbucoderWxuser;
import com.ruoyi.abuwx.service.IAbucoderWxuserService;
import com.ruoyi.dazhuwx.domain.DazhuMarkersInfo;
import com.ruoyi.dazhuwx.service.DazhuMarkersInfoService;
import com.ruoyi.dazhuwx.mapper.DazhuMarkersInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author 95155
* @description 针对表【dazhu_markers_info(标点信息表)】的数据库操作Service实现
* @createDate 2024-11-25 15:43:21
*/
@Slf4j
@Service
public class DazhuMarkersInfoServiceImpl extends ServiceImpl<DazhuMarkersInfoMapper, DazhuMarkersInfo>
        implements DazhuMarkersInfoService {

    @Resource
    DazhuMarkersInfoService dazhuMarkersInfoService;
    @Resource
    private IAbucoderWxuserService iAbucoderWxuserService;

    @Override
    public boolean saveAll(DazhuMarkersInfo dazhuMarkersInfo) {
        Double latitude = dazhuMarkersInfo.getLatitude();
        Double longitude = dazhuMarkersInfo.getLongitude();
        String openid = dazhuMarkersInfo.getOpenid();
        AbucoderWxuser abucoderWxuser = iAbucoderWxuserService.selectAbucoderWxuserOpenID(openid);
        if (abucoderWxuser != null) {
            dazhuMarkersInfo.setNickName(abucoderWxuser.getNickname());
            dazhuMarkersInfo.setAvatar(abucoderWxuser.getAvatar());
            dazhuMarkersInfo.setUserId(String.valueOf(abucoderWxuser.getId()));
        }else {
            log.error("查找不到当前用户，不允许新增标点");
            return false;
        }
        return dazhuMarkersInfoService.save(dazhuMarkersInfo);
    }
}



